home *** CD-ROM | disk | FTP | other *** search
/ Power Tools for Macintosh / Power Tools for Macintosh (SoftBit)(1992).iso / Stacks / *S-Z / Script Stripper / ~Script Stripper Textfiles / Script Stripper v2.0.strip
Encoding:
Text File  |  1993-06-05  |  15.6 KB  |  424 lines  |  [TEXT/MACA]

  1. "Script Stripper 2.0" HyperCard script extractor.
  2. ©1992, 1993. Donald J. Winiecki, all rights reserved.
  3. ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
  4.  
  5. • Name of Stack: "Script Stripper v2.0"
  6. • Size of Stack: 31.36 KB.
  7. • Free Space in Stack: 0 KB.
  8. • User Level of Stack: 5; "Scripting"
  9.  
  10. • Date of Stripping: Saturday, June 5, 1993
  11. • Time of Stripping: 7:09 PM
  12.  
  13. ◊ ◊ Starting scripts of Stack: "Script Stripper v2.0" ◊ ◊
  14.  
  15. • • Script of Stack: "Script Stripper v2.0" • •
  16. _____________________________________________________
  17. 2.0
  18.  
  19. on openStack
  20.   hide menuBar
  21.   aboutTheStripper
  22.   put line 1 of script of this stack into bg fld "the version of"
  23. end openStack
  24.  
  25. on closeStack
  26.   show menuBar
  27. end closeStack
  28.  
  29. on aboutTheStripper
  30.   put "About Script Stripper..." into menuItem 1 of menu "Apple" with ¬
  31.   menuMsg "about"
  32. end aboutTheStripper
  33.  
  34. on about
  35.   -- use "Hard Spaces" (eg: <Option-Space>) to create formatted
  36.   -- output in a dialog box
  37.   answer "    ""e&"Script Stripper,""e&&"a HyperCard script"¬
  38.   &&"            extraction utility."¬
  39.   &&" _____________________________________"¬
  40.   &&"        ©1993, Donald J. Winiecki"¬
  41.   &&"         5202 Bangor Ave., H 204"¬
  42.   &&"                      Lubbock, TX. 79414"¬
  43.   &&"             {806} 792-5253" with "More..." or "Done"
  44.   if it = "More..." then
  45.     lock screen
  46.     show cd fld "Stripper Help"
  47.     show cd btn "Hide Stripper Help"
  48.     set the hilite of cd btn "Hide Stripper Help" to true
  49.     set the scroll of cd fld "Stripper Help" to 533 -- go to specific point in "Help" field
  50.     unlock screen with scroll down
  51.   end if
  52. end about
  53.  
  54. on checkIfCompactNeeded
  55.   -- keep the stack lean (copying & moving text builds LOTS of freespace)
  56.   -- this handler is from pp. 207 of "The Complete Book of HyperTalk 2, by Dan Shafer
  57.   put size of this stack into stackSize
  58.   put freeSize of this stack into freeSpace
  59.   if freeSpace > (.3 * stackSize) then -- if freeSpace exceeds 30% of stack's size
  60.     answer "  ""e&"Script Stripper""e&&"should be compacted"¬
  61.     &&"          before we continue." with "Ok"
  62.     doMenu "Compact Stack"
  63.   end if
  64. end checkIfCompactNeeded
  65.  
  66. on whereItsSaved
  67.   global thisStack, stackNameTruncated_G
  68.   if stackNameTruncated_G is not empty then
  69.     -- if the ".strip" file name had to be truncated •• (6/5/93)
  70.     answer "Scripts for:"&"e&stackNameTruncated_G"e&&"have been saved in"¬
  71.     &&"the"&"e&"~Script Stripper Textfiles""e&&"folder"¬
  72.     &&"as:"&"e&stackNameTruncated_G&".strip.""e with "Oh Boy !"
  73.   else
  74.     answer "Scripts for:"&"e&thisStack"e&&"have been saved in"¬
  75.     &&"the"&"e&"~Script Stripper Textfiles""e&&"folder"¬
  76.     &&"as:"&"e&thisStack&".strip.""e with "Oh Boy !"
  77.   end if
  78. end whereItsSaved
  79.  
  80. function underScore
  81.   -- declare and use a function instead of typing this thing every time
  82.   return "_____________________________________________________"
  83. end underScore
  84.  
  85. on retrieveStackScript
  86.   global thisStack_G, thisStack, stackNameTruncated_G
  87.   push card -- remember where to come back to
  88.   put empty into thisStack
  89.   put empty into thisStack_G
  90.   put empty into stackNameTruncated_G
  91.   
  92.   -- find the short name of the "Script Stripper"
  93.   repeat with i = number of chars in long name of this stack down to 1
  94.     set cursor to busy
  95.     -- keep the last item in the path statement
  96.     if char i of long name of this stack = ":" then exit repeat
  97.     put char i of long name of this stack before temp
  98.   end repeat
  99.   
  100.   -- establish the path to where the "Stripped" script will be stored {stored in 'filePath'}
  101.   -- (!!!!user should not change file/folder names or location of the "...Textfiles" folder)
  102.   repeat with i = 8 to (number of chars in long name of this stack - (number of chars in temp + 1))
  103.     set cursor to busy
  104.     put char i of long name of this stack after filePath
  105.   end repeat
  106.   
  107.   -- request user to maneuver to and identify stack to be stripped
  108.   -- full path to the desired stack is put into "it"
  109.   answer file "Strip which stack's scripts ?" of type "STAK"
  110.   
  111.   -- if user decides not to do it then bail out...
  112.   if it is empty then
  113.     answer " Script Stripping Operation Aborted!" with "Whew !"
  114.     exit retrieveStackScript
  115.   end if
  116.   
  117.   -- store the full path name of the stack to be stripped into global variable 'thisStack_G'
  118.   put it into thisStack_G
  119.   
  120.   -- establish the name of the textfile to be created for this stripping session
  121.   repeat with i = number of chars in thisStack_G down to 1
  122.     set cursor to busy
  123.     if char i of thisStack_G = ":" then exit repeat
  124.     put char i of thisStack_G before thisStack
  125.   end repeat
  126.   
  127.   -- write my tag line into the holder variable (strippingHolder)
  128.   put quote&"Script Stripper"&&line 1 of script of this stack"e&&"HyperCard"¬
  129.   &&"script extractor."&return&"©1992, 1993. Donald J. Winiecki, all rights reserved."&return ¬
  130.   &"∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞"&return&return into strippingHolder
  131.   
  132.   set lockMessages to true
  133.   lock screen
  134.   go stack thisStack_G
  135.   
  136.   -- write the selected stack's script after holder variable
  137.   put "• Name of Stack:"&"e&thisStack"e&return after strippingHolder
  138.   
  139.   -- write some stack statistics
  140.   put the userLevel into it
  141.   if it = 1 then put "1;"&"e&"Browsing""e into it
  142.   if it = 2 then put "2;"&"e&"Typing""e into it
  143.   if it = 3 then put "3;"&"e&"Painting""e into it
  144.   if it = 4 then put "4;"&"e&"Authoring""e into it
  145.   if it = 5 then put "5;"&"e&"Scripting""e into it
  146.   put "• Size of Stack:"&&size of this stack / 1000&&"KB."&return after strippingHolder
  147.   put "• Free Space in Stack:"&&the freeSize of this stack / 1000&&"KB."&return after strippingHolder
  148.   put "• User Level of Stack:"&&it&return&return after strippingHolder
  149.   put "• Date of Stripping:"&&the long date&return after strippingHolder
  150.   put "• Time of Stripping:"&&the time&return&return after strippingHolder
  151.   put "◊ ◊ Starting scripts of Stack:"&"e&thisStack"e&" ◊ ◊"&return&return after strippingHolder
  152.   put "• • Script of Stack:"&"e&thisStack"e&" • •"&return after strippingHolder
  153.   put underScore()&return after strippingHolder
  154.   if script of stack thisStack_G is not empty then
  155.     put script of stack thisStack_G after strippingHolder
  156.   else
  157.     put "* No script at the Stack Level" after strippingHolder
  158.   end if
  159.   put return&return after strippingHolder
  160.   
  161.   go to first cd of stack thisStack_G
  162.   
  163.   repeat with i = 1 to the number of bgs
  164.     go bg i
  165.     set cursor to busy
  166.     put empty into j
  167.     put empty into k
  168.     
  169.     put "• ◊ Scripts of Background"&&i&";"&"e&short name of this bg¬
  170.     "e&return after strippingHolder
  171.     put underScore()&return after strippingHolder
  172.     if script of bg i is empty then
  173.       put "* No script for this Background" after strippingHolder
  174.     else
  175.       put script of bg i after strippingHolder
  176.     end if
  177.     put return&return after strippingHolder
  178.     
  179.     repeat with k = 1 to number of bg btns
  180.       set cursor to busy
  181.       put "• Script of Background Button:"&&k&";"&"e&short name of bg btn k¬
  182.       "e&&"of Background"&&i&return after strippingHolder
  183.       put underScore()&return after strippingHolder
  184.       if script of bg btn k is empty then
  185.         put "* No script for this Background Button" after strippingHolder
  186.       else
  187.         put script of bg btn k after strippingHolder
  188.       end if
  189.       put return&return after strippingHolder
  190.     end repeat
  191.     
  192.     repeat with j = 1 to number of bg flds
  193.       set cursor to busy
  194.       put "• Script of Background Field"&&j&";"&"e&short name of bg fld j¬
  195.       "e&&"of Background"&&i&return after strippingHolder
  196.       put underScore()&return after strippingHolder
  197.       if script of bg fld j is empty then
  198.         put "* No script for this Background Field" after strippingHolder
  199.       else
  200.         put script of bg fld j after strippingHolder
  201.       end if
  202.       put return&return after strippingHolder
  203.     end repeat
  204.     
  205.     repeat with L = 1 to number of cds of bg i
  206.       go cd L of bg i
  207.       put empty into m
  208.       put empty into n
  209.       
  210.       set cursor to busy
  211.       put "• Script of Card:"&&L&";"&"e&short name of cd L of this bg¬
  212.       "e&&"of Background"&&i&return after strippingHolder
  213.       put underScore()&return after strippingHolder
  214.       if script of cd L of this bg is empty then
  215.         put "* No script for this Card" after strippingHolder
  216.       else
  217.         put script of cd L of this bg after strippingHolder
  218.       end if
  219.       put return&return after strippingHolder
  220.       
  221.       repeat with n = 1 to number of cd btns
  222.         set cursor to busy
  223.         put "• Script of Card Button:"&&n&";"&"e&short name of cd btn n¬
  224.         "e&&"of Card"&&L&&"of Background"&&i&return after strippingHolder
  225.         put underScore()&return after strippingHolder
  226.         if script of cd btn n is empty then
  227.           put "* No script for this Card Button" after strippingHolder
  228.         else
  229.           put script of cd btn n after strippingHolder
  230.         end if
  231.         put return&return after strippingHolder
  232.       end repeat
  233.       
  234.       repeat with m = 1 to number of cd flds
  235.         set cursor to busy
  236.         put "• Script of Card Field:"&&m&";"&"e&short name of cd fld m¬
  237.         "e&&"of Card"&&L&&"of Background"&&i&return after strippingHolder
  238.         put underScore()&return after strippingHolder
  239.         if script of cd fld m is empty then
  240.           put "* No script for this Card Field" after strippingHolder
  241.         else
  242.           put script of cd fld m after strippingHolder
  243.         end if
  244.         put return&return after strippingHolder
  245.       end repeat
  246.     end repeat
  247.   end repeat
  248.   
  249.   -- stacks with long names cause problems with "Script Stripper"
  250.   -- at this point in the handler. The handler has therefore been
  251.   -- designed to truncate long script names and store the stripped file
  252.   -- using a shortened version of the original stack name (the original
  253.   -- stack's name is not changed). •• (6/5/93)
  254.   
  255.   if the number of chars in thisStack > 27 then -- file names limited to 31 char's here
  256.     put the number of chars in thisStack into nameThisLong
  257.     put char 1 to 10 of thisStack into stackNameTruncated_G
  258.     put "..." after stackNameTruncated_G
  259.     put char (nameThisLong - 10) to nameThisLong of thisStack after stackNameTruncated_G
  260.   end if
  261.   
  262.   -- write the variable contents to the textfile named for the stack
  263.   if stackNameTruncated_G is not empty then -- if the stack name was too long
  264.     open file filePath&":"&"~Script Stripper Textfiles"&":"&stackNameTruncated_G&".strip"
  265.     write strippingHolder to file filePath&":"&"~Script Stripper Textfiles"&":"&stackNameTruncated_G&".strip"
  266.     close file filePath&":"&"~Script Stripper Textfiles"&":"&stackNameTruncated_G&".strip"
  267.   else
  268.     open file filePath&":"&"~Script Stripper Textfiles"&":"&thisStack&".strip"
  269.     write strippingHolder to file filePath&":"&"~Script Stripper Textfiles"&":"&thisStack&".strip"
  270.     close file filePath&":"&"~Script Stripper Textfiles"&":"&thisStack&".strip"
  271.   end if
  272.   
  273.   pop card -- come back to where we left
  274.   unlock screen
  275.   
  276.   if the number of chars in strippingHolder < 29900 then
  277.     -- only 30000 characters can be held in a HyperCard field
  278.     answer "Would you like to view the scripts for stack:"&"e&thisStack"e¬
  279.     &&"now?" with "Later" or "Yes"
  280.     if it = "Yes" then
  281.       lock screen
  282.       show cd pict
  283.       repeat with i = 1 to (number of cd btns - 1)
  284.         -- show all buttons except "Hide Help"
  285.         show cd btn i
  286.       end repeat
  287.       show bg fld "Editing Field"
  288.       hide bg btn "Go Home"
  289.       put strippingHolder into bg fld "Editing Field"
  290.       unlock screen with barn door open
  291.     else
  292.       whereItsSaved
  293.     end if
  294.   else
  295.     answer "The scripts for"&"e&thisStack"e&&"are"¬
  296.     &&"too long to view within the Script Stripper, use TeachText or your"¬
  297.     &&"word processor to open the file instead." with "Okay"
  298.     
  299.     -- tell the user where the textfiles are saved
  300.     whereItsSaved
  301.   end if
  302.   
  303.   set lockMessages to false
  304. end retrieveStackScript
  305.  
  306. • ◊ Scripts of Background 1; "Stripper bg 1"
  307. _____________________________________________________
  308. * No script for this Background
  309.  
  310. • Script of Background Button: 1; "Help" of Background 1
  311. _____________________________________________________
  312. on mouseUp
  313.   lock screen
  314.   show cd btn "Hide Stripper Help"
  315.   hide cd btn "Done Viewing"
  316.   hide cd btn "Print Scripts"
  317.   hide bg btn "Info"
  318.   hide bg btn "Help"
  319.   set the hilite of cd btn "Hide Stripper Help" to true
  320.   show cd fld "Stripper Help"
  321.   unlock screen with scroll down
  322. end mouseUp
  323.  
  324. • Script of Background Button: 2; "Go Home" of Background 1
  325. _____________________________________________________
  326. on mouseUp
  327.   checkIfCompactNeeded
  328.   go home
  329. end mouseUp
  330.  
  331. • Script of Background Button: 3; "Info" of Background 1
  332. _____________________________________________________
  333. on mouseUp
  334.   about
  335. end mouseUp
  336.  
  337. • Script of Background Button: 4; "Load A Script" of Background 1
  338. _____________________________________________________
  339. on mouseUp
  340.   retrieveStackScript
  341. end mouseUp
  342.  
  343. • Script of Background Field 1; "the version of" of Background 1
  344. _____________________________________________________
  345. * No script for this Background Field
  346.  
  347. • Script of Background Field 2; "Editing Field" of Background 1
  348. _____________________________________________________
  349. * No script for this Background Field
  350.  
  351. • Script of Card: 1; "Stripper cd 1" of Background 1
  352. _____________________________________________________
  353. * No script for this Card
  354.  
  355. • Script of Card Button: 1; "Done Viewing" of Card 1 of Background 1
  356. _____________________________________________________
  357. on mouseUp
  358.   global thisStack
  359.   whereItsSaved
  360.   lock screen
  361.   repeat with i = 1 to (number of cd btns - 1)
  362.     -- hide all card buttons except "Hide Help"
  363.     hide cd btn i
  364.   end repeat
  365.   hide cd pict
  366.   hide bg fld "Editing Field"
  367.   show bg btn "Go Home"
  368.   set the scroll of bg fld "Editing Field" to 0
  369.   put empty into bg fld "Editing Field"
  370.   unlock screen with barn door close
  371.   checkIfCompactNeeded
  372. end mouseUp
  373.  
  374. • Script of Card Button: 2; "Print Scripts" of Card 1 of Background 1
  375. _____________________________________________________
  376. on mouseUp
  377.   print bg fld "Editing Field"
  378. end mouseUp
  379.  
  380. • Script of Card Button: 3; "scroll up" of Card 1 of Background 1
  381. _____________________________________________________
  382. on mouseStillDown
  383.   set the hilite of me to true
  384.   set the scroll of bg fld "Editing Field" to¬
  385.   (scroll of bg fld "Editing Field" - (3 * textSize of bg fld¬
  386.   "Editing Field"))
  387. end mouseStillDown
  388.  
  389. • Script of Card Button: 4; "scroll down" of Card 1 of Background 1
  390. _____________________________________________________
  391. on mouseStillDown
  392.   set the hilite of me to true
  393.   set the scroll of bg fld "Editing Field" to¬
  394.   (scroll of bg fld "Editing Field" + (3 * textSize of bg fld¬
  395.   "Editing Field"))
  396. end mouseStillDown
  397.  
  398. • Script of Card Button: 5; "Hide Stripper Help" of Card 1 of Background 1
  399. _____________________________________________________
  400. on mouseUp
  401.   set the hilite of me to not the hilite of me
  402.   lock screen
  403.   hide cd fld "Stripper Help"
  404.   hide cd btn "Hide Stripper Help"
  405.   if the visible of bg fld "Editing Field" is true then
  406.     show cd btn "Print Scripts"
  407.     show cd btn "Done Viewing"
  408.   end if
  409.   show bg btn "Info"
  410.   show bg btn "Help"
  411.   -- return to the beginning of the field
  412.   set the scroll of cd fld "Stripper Help" to 0
  413.   unlock screen with scroll up
  414. end mouseUp
  415.  
  416. • Script of Card Field: 1; "Stripper Help" of Card 1 of Background 1
  417. _____________________________________________________
  418. -- It's usually a good idea to use "default" fonts for your fields.
  419. -- If you set them to "fancy fonts" some user's (whose machines
  420. -- don't have your font installed) won't be able to see the stack
  421. -- as you've intended. In some cases, the copy will become difficult
  422. -- to read because the Macintosh tries to "estimate" the unknown font.   d.j.w.
  423.  
  424.